<template>
  <a-card :bordered="false">
    <div style="display: flex; justify-content: space-between">
      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('订单表')">导出</a-button>
      <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
      </div>
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <div>
            <a-form-item label="城市服务商" style="margin-right: 10px" v-has="'xhdjBillingInformation:select'">
              <serveSelect @selectClick="selectClick" :value="queryParam.agencyCode"></serveSelect>
            </a-form-item>
          </div>
          <div>
            <a-form-item label="通知状态" style="margin-right: 10px">
              <a-select v-model="queryParam.isInform" style="width: 120px" placeholder="请选择">
                <a-select-option value="1"> 是 </a-select-option>
                <a-select-option value="0"> 否 </a-select-option>
              </a-select>
            </a-form-item>
          </div>
          <div>
            <a-form-item label="交易渠道类型" style="margin-right: 10px">
              <a-select v-model="queryParam.payType" style="width: 120px" placeholder="请选择">
                <a-select-option value="1"> 余额 </a-select-option>
                <a-select-option value="2"> 支付宝 </a-select-option>
                <a-select-option value="3"> APP微信(备用) </a-select-option>
                <a-select-option value="4"> 微信公众号(备用)</a-select-option>
                <a-select-option value="5"> 微信公众号(备用) </a-select-option>
                <a-select-option value="6"> 微信公众号(商户备用) </a-select-option>
                <a-select-option value="7"> 微信公众号(商户1674799970) </a-select-option>
              </a-select>
            </a-form-item>
          </div>
          <div>
            <a-form-item label="支付状态" style="margin-right: 10px">
              <a-select v-model="queryParam.status" style="width: 120px" placeholder="请选择">
                <a-select-option value="0"> 待支付 </a-select-option>
                <a-select-option value="1"> 已支付 </a-select-option>
                <a-select-option value="2"> 失败 </a-select-option>
                <a-select-option value="3"> 已取消 </a-select-option>
              </a-select>
            </a-form-item>
          </div>
          <div>
            <a-form-item label="交易类型" style="margin-right: 10px">
              <a-select v-model="queryParam.scanType" style="width: 120px" placeholder="请选择">
                <a-select-option value="0"> 预约服务项目 </a-select-option>
                <a-select-option value="1"> 充值 </a-select-option>
                <a-select-option value="2"> 退款 </a-select-option>
                <a-select-option value="3"> 购买物料 </a-select-option>
                <a-select-option value="4"> 物料退款 </a-select-option>
              </a-select>
            </a-form-item>
          </div>
          <div>
            <a-form-item label="来源订单号" style="margin-right: 10px">
              <a-input placeholder="请输入" v-model="queryParam.sn"></a-input>
            </a-form-item>
            <a-form-item label="商户订单号" style="margin-right: 10px">
              <a-input placeholder="请输入" v-model="queryParam.tradeNo"></a-input>
            </a-form-item>
          </div>
          <div>
            <a-form-item label="开始时间" style="margin-right: 10px">
              <a-date-picker v-model="queryParam.startTime" :valueFormat="'YYYY-MM-DD'" @change="startChange" />
            </a-form-item>
            <a-form-item label="结束时间" style="margin-right: 10px">
              <a-date-picker
                v-model="queryParam.endTime"
                :valueFormat="'YYYY-MM-DD'"
                @change="endChange"
                :disabled-date="disabledDate"
              />
            </a-form-item>
          </div>
          <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
          </span>
        </a-form>
      </div>
    </div>
    <!-- table区域-begin -->
    <!-- <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="1"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      class="j-table-force-nowrap"
      @change="handleTableChange"
    >
      <span slot="action" slot-scope="text, record">
        <a @click="handleEdit(record)">编辑</a>
        <a-divider type="vertical" />
        <a-dropdown>
          <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
          <a-menu slot="overlay">
            <a-menu-item>
              <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                <a>删除</a>
              </a-popconfirm>
            </a-menu-item>
          </a-menu>
        </a-dropdown>
      </span>
    </a-table>
    <!-- table区域-end -->
  </a-card>
</template>
<script>
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import serveSelect from '@/components/serveSelect.vue'
import moment from 'moment'
export default {
  name: 'xhdjFundLog',
  mixins: [JeecgListMixin],
  components: { serveSelect },
  data () {
    return {
      description: '订单表管理页面',
      payTypes: {
        1: '会员余额',
        2: 'APP支付宝',
        3: 'APP微信(商户备用)',
        4: '微信公众号(商户备用)',
        5: '微信公众号(商户备用)',
        6: '微信公众号(商户备用)',
        7: '微信公众号(商户1674799970)',
      },
    // (0预约服务项目，1充值，2:服务退款 3物料购买 4物料退款)
      scanTypes: {
        0: '预约服务项目',
        1: '充值',
        2: '服务订单退款',
        3: '物料购买',
        4: '物料退款',
      },


      columns: [
        {
          title: '用户/技师编号',
          align: 'center',
          dataIndex: 'userId'
        },
        {
          title: '用户/技师名称',
          align: 'center',
          dataIndex: 'userName'
        },
        {
          title: '是否已通知',
          align: 'center',
          dataIndex: 'isInform',
          customRender: (text, record) => {
            return record.isInform === 0 ? '否 ' : '是'
          }
        },
        {
          title: '商户订单号',
          align: 'center',
          dataIndex: 'tradeNo'
        },
        {
          title: '来源订单号',
          align: 'center',
          dataIndex: 'sn'
        },
        {
          title: '交易渠道类型',
          align: 'center',
          dataIndex: 'payType',
          customRender: (text, record) => {
            return this.payTypes[record.payType]
          }
        },
        {
          title: '交易类型',
          align: 'center',
          dataIndex: 'scanType',
          customRender: (text, record) => {
            return this.scanTypes[record.scanType]
          }
        },
        {
          title: '实际出入账单金额',
          align: 'center',
          dataIndex: 'amount'
        },
        {
          title: '账单总金额',
          align: 'center',
          dataIndex: 'totalAmount'
        },
        {
          title: '支付状态',
          align: 'center',
          dataIndex: 'status',
          customRender: (text, record) => {
            return record.status === 0
              ? '待支付 '
              : record.status === 1
              ? '已支付'
              : record.status === 2
              ? '失败'
              : '已取消'
          }
        },
        {
          title: '创建时间',
          align: 'center',
          dataIndex: 'createTime'
        }
      ],
      url: {
        list: '/finance/xhdjPayTransaction/backList'
      }
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    startChange (value) {
      if (value) {
        this.queryParam.startTime = value + ' 00:00:00'
      } else {
        this.queryParam.startTime = value
      }
    },
    selectClick (value) {
      this.queryParam.agencyCode = value
      this.searchQuery()
    },
    endChange (value) {
      if (value) {
        this.queryParam.endTime = value + ' 23:59:59'
      } else {
        this.queryParam.endTime = value
      }
    },
    disabledDate (time) {
      return new Date(time).getTime() < new Date(this.queryParam.startTime).getTime()
    }
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
.ant-row {
  display: flex;
  justify-content: flex-end;
}
.ant-col {
  display: flex;
  justify-content: flex-end;
}
.ant-form {
  display: flex;
}
</style>
